package top.lanscarlos.ashcraft.service;

import com.sun.istack.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import top.lanscarlos.ashcraft.pojo.Seller;
import top.lanscarlos.ashcraft.repository.SellerRepository;

import java.util.List;

/**
 * Ashcraft
 * top.lanscarlos.ashcraft.service
 *
 * @author Lanscarlos
 * @since 2022-05-26 20:34
 */
@Service
public class SellerService {
    @Autowired
    private SellerRepository repository;

    public List<Seller> query(@Nullable String name) {
        return repository.query(name);
    }

    @Nullable
    public Seller register(
            @NotNull String name,
            @NotNull String password,
            @Nullable String avatar,
            @Nullable String description,
            @NotNull String contact
    ) {
        Seller seller = new Seller(name, password, avatar, description, contact);
        return repository.insert(seller) ? seller : null;
    }
}
